package vip.specimen.system.datasource.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

/**
 * *@Author: 余浪人
 * *@Date：2021/2/23 17:04
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
// 系统角色实体
@Getter
@Setter
@Entity
@Table(name = "system_role")
public class SystemRoleEntity extends BaseEntity {
    @ApiModelProperty(value = "角色名称")
    private String roleName;
    @ApiModelProperty(value = "角色标识")
    private String roleCode;  // 角色标识程序中判断使用,如"admin",这个是唯一的:
    @Column(length = 1024)
    @ApiModelProperty(value = "角色描述")
    private String roleDescription;
    @ApiModelProperty(value = "状态",dataType = "int")
    private int roleStatus; // 1：启用 2：停用
    @Column(length = 1024)
    @ApiModelProperty(value = "角色备注")
    private String roleRemark; // 备注
    @ApiModelProperty(value = "角色权限",dataType = "List")
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "system_role_permission", joinColumns = {@JoinColumn(name = "system_role_uuid")}, inverseJoinColumns = {@JoinColumn(name = "system_permission_uuid")})
    private List<SystemPermissionEntity> permission;
//    @ManyToMany
//    @JoinTable(name = "system_role_user", joinColumns = {@JoinColumn(name = "system_role_uuid")}, inverseJoinColumns = {@JoinColumn(name = "system_user_uuid")})
//    private List<SystemUserEntity> userInfos; // 一个角色对应多个用户


    public SystemRoleEntity() {
    }

    public SystemRoleEntity(String roleName, String roleCode, String roleDescription, int roleStatus, String roleRemark, List<SystemPermissionEntity> permission) {
        this.roleName = roleName;
        this.roleCode = roleCode;
        this.roleDescription = roleDescription;
        this.roleStatus = roleStatus;
        this.roleRemark = roleRemark;
        this.permission = permission;
    }
}